<?php 
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Main</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/bootstrap-datepicker3.css" rel="stylesheet" />
<link href="Content/site.css" rel="stylesheet" />
<script src="Scripts/jquery-1.9.1.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/bootstrap-datepicker.js"></script>
</head>
<body>
<div class="container blue_border">
<?php 
include_once("php/banner.php");
?>
<?php 
include_once("php/nav_bar.php");
?>

 <div class="container-fluid">
   
              <?php	include_once("php/main_classes.php");?>
              <?php	include_once("php/all_seasons.php");?>
            <?php	include_once("php/all_divisions.php");?>
            <div class="col-md-12">
            Round
            <?php 
			$roundId = $repRound->getRoundByDate($today);
			$schedles=$repSchedule->maps($repSchedule->getScheduleByRoundID($roundId));
			$season=$repSeason->map($repSeason->getSeasonByDate($today));
			$rounds=$repRound->maps($repRound->getAllRoundsDESC($season->seasonID));
			
			foreach ($rounds as $r){
			?>
            <a href="history_round.php?id=<?php echo $r->roundID;?>"><?php echo " ".$r->round_number." ";?></a>
            <?php } ?>
            <h3>Round <?php echo $roundId; ?> </h3>
        </div>
            <?php  $n=1; foreach ($divisions as $div){ $divID=$div->divisionID; $n++;?> 
     <?php if ($n%2!=0) echo '<div class="row">'; ?> 
	 <?php include("php/main_variables.php");?>
      <div class="col-lg-6 col-md-6">
        <div class="list-group">
          <div class="list-group-item list-group-item-info">        
            <?php echo $d->division_name;?> 
          </div>
          	<?php 

			foreach ($schedles as $s){
			include("php/main_teams_open.php");	
			if ($team1->divisionID==$divID){?>
          <a class="list-group-item a-block" href="round2teams_result.php?id=<?php echo $s->round_scheduleID;?>">
          <div class="container-fluid">
            <div class="row">
              <div class="col-xs-5 text-center">
                <div class="team-font"> 
					<?php echo $team1->team_name;?> 
                </div>
                <?php $winLostTeamMatches=$repCalc->countTeamWonMatches($s->round_scheduleID);?>
                <div class="score-font <?php 
				if ( $winLostTeamMatches['winTeam1']>$winLostTeamMatches['winTeam2'])
					echo "score-win";
				else if ( $winLostTeamMatches['winTeam1']<$winLostTeamMatches['winTeam2'])
					echo "score-loose";?>">
                <?php echo $winLostTeamMatches['winTeam1']; ?>
                </div>
              </div>
              <div class="col-xs-2 text-center vs-style vs-inner">vs</div>
              <div class="col-xs-5 text-center">
                <div class="team-font"> 
					<?php echo $team2->team_name;?> 
                </div>
                <div class="score-font <?php 
				if ( $winLostTeamMatches['winTeam2']>$winLostTeamMatches['winTeam1'])
					echo "score-win";
				else if ( $winLostTeamMatches['winTeam1']>$winLostTeamMatches['winTeam2'])
					echo "score-loose";?>">
                    <?php echo $winLostTeamMatches['winTeam2']; ?>
                    </div>
              </div>
            </div>
          </div>
          </a>
          <?php	}	}	?>
          
       <?php if ($n%2!=0) echo '</div>'; ?>  
      </div>
      </div>
<?php	} ?>

      
	

  </div>


  <?php 
  ob_flush();
include_once("php/footer.php");
?>
</div>
</body>
</html>
